//
//  VCOfThird.m
//  UI07_UINavigationController
//
//  Created by Scott on 16/5/11.
//  Copyright © 2016年 Scott. All rights reserved.
//

#import "VCOfThird.h"

@interface VCOfThird ()

@end

@implementation VCOfThird

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    [self buttonBackView];
}

- (void)buttonBackView {
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    button.frame = CGRectMake(0, 0, 300, 100);
    button.center = self.view.center;
    [self.view addSubview:button];
    
    [button setTitle:@"Back" forState:UIControlStateNormal];
    button.backgroundColor = [UIColor yellowColor];
    
    [button addTarget:self action:@selector(handleBack) forControlEvents:UIControlEventTouchUpInside];
    

}

- (void)handleBack {
    
    NSLog(@"stack:%@", self.navigationController.viewControllers);
    // 出栈.
    
//    [self.navigationController popViewControllerAnimated:YES];
    
//    [self.navigationController popToRootViewControllerAnimated:YES];
    
    [self.navigationController popToViewController:self.navigationController.viewControllers[1] animated:YES];
    
    
    
}


@end
